using System;
using Machine.Specifications;

namespace Avinor.NET.Specs.QueryBuilders
{
    [Subject(typeof(FlightsQuery))]
    public class when_initializing_querybuilder
    {
        static string _query;
        Because of = () =>
        {
            _query = new FlightsQuery("SVG").Query;
        };

        It should_return_correct_airportquerystring = () =>
        {
            _query.ShouldEqual("airport=SVG");
        };
    }

    [Subject(typeof(FlightsQuery))]
    public class when_creating_query_for_arrivals
    {
        static string _query;
        Because of = () =>
        {
            _query = new FlightsQuery("SVG").Arrivals().Query;
        };

        It shouldQuery_contain_direction_equals_A = () =>
        {
            _query.ShouldContain("direction=A");
        };
    }

    [Subject(typeof(FlightsQuery))]
    public class when_creating_query_for_departures
    {
        static string _query;
        Because of = () =>
        {
            _query = new FlightsQuery("SVG").Departures().Query;
        };

        It shouldQuery_contain_direction_equals_D = () =>
        {
            _query.ShouldContain("direction=D");
        };
    }

    [Subject(typeof(FlightsQuery))]
    public class when_creating_query_for_1_hour_back
    {
        static string _query;
        Because of = () =>
        {
            _query = new FlightsQuery("SVG").HoursBack(1).Query;
        };

        It shouldQuery_contain_timeFrom_equals_1 = () =>
        {
            _query.ShouldContain("timeFrom=1");
        };
    }
    [Subject(typeof(FlightsQuery))]
    public class when_creating_query_for_2_hours_forward
    {
        static string _query;
        Because of = () =>
        {
            _query = new FlightsQuery("SVG").HoursForward(2).Query;
        };

        It shouldQuery_contain_timeTo_equals_2 = () =>
        {
            _query.ShouldContain("timeTo=2");
        };
    }

    [Subject(typeof(FlightsQuery))]
    public class when_creating_query_for_updates_after_a_spesific_time
    {
        static string _query;
        Because of = () =>
        {
            _query = new FlightsQuery("SVG").UpdatedAfter(new DateTime(2009,2,3,9,30,0)).Query;
        };

        It shouldQuery_contain_lastUpdate_equals_2009_02_03T09_30_00 = () =>
        {
            _query.ShouldContain("lastUpdate=2009-02-03T09:30:00");
        };
    }
}
